﻿<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="bin\debug\CustomTasks.tasks" />

  <PropertyGroup >
    <VisualStudioDir>C:\Program Files (x86)\Microsoft Visual Studio 10.0\</VisualStudioDir>
    <MSTest>$(VisualStudioDir)Common7\IDE\mstest.exe</MSTest>
    <CodeMetrics>$(VisualStudioDir)Team Tools\Static Analysis Tools\FxCop\Metrics.exe</CodeMetrics>
  </PropertyGroup>

  <!--Running all tests from a given solution. In Debug mode, excluding the acceptance tests project.
  output will be written in TestResults.trx file-->
  <Target Name="UnitTests">
    <Message Text="Executing Unit Tests" />
    <RunAllTestsInSolution
              MSTest ="$(MSTest)"
              SolutionFile="MyProject.sln"
              Parmaters ="/resultsfile:TestResults.trx"
              ExcludeProject="AcceptanceTests"
              Configuration="Debug"
              />
  </Target>

  <!--Running all tests from a given solution, using NCover to gather coverage data.
  In Debug mode, excluding the acceptance tests project.
  Coverage output will be written in CoverageResults.xml file-->
  <Target Name="UnitTests">
    <Message Text="Executing Unit Tests With Coverage" />
    <NCoverAllTestInSolution
            NCoverConsole="$(Ncover)"
            MSTest ="$(MSTest)"
            SolutionFile="MyProject.sln"
            Parmaters ="/resultsfile:TestResults.trx //x CoverageResults.xml"
            Configuration="$(configuration)"
             />
  </Target>

  <!-- Converting MSTest binary coverage data into an xml file and than using xsl to create a viewable HTML.
  the coverage data is taken from a specified location that is configured in the testsetting file, 
  creates an intermediate xml file which is than transformed to the final HTML file
  -->
  <Target Name="CoverageReport" >
    <Message Text="Processing code coverage results..." />
    <!--<ConvertCoverage CoverageFile="OutputDirectory\In\$(ComputerName)\data.coverage"
                     SymbolsDirectory="OutputDirectory\Out"
                     OutputFile="CoverageReport.xml"/>-->
    <Exec Command="TransformXml.exe -i CoverageReport.xml -s xsl\MsCoverageReport.xsl > CoverageReport.html" />
  </Target>



  
  <!--Using the coverage filtering ability-->
  <Target Name="Filter">
    <FilterCoverage
      CoverageFile="E:\Users\lior\Documents\Visual Studio 2008\Projects\CustomTasks\FilterCoverage\TestData\FullCoverageReport.xml"
      OutputFile = "E:\Users\lior\Documents\Visual Studio 2008\Projects\CustomTasks\FilterCoverage\TestData\efwOutput.xml"
      />
  </Target>

  <!--running coverage on native exe (googleTest)-->
  <Target Name="UnitTestsWithCoverage">
    <RunTestsWithCoverage FileName ="bin\debug\ECM.exe"
              OutputDirectory="CoverageResults"
              PerformanceToolsDir="c:\Program Files (x86)\Microsoft Visual Studio 9.0\Team Tools\Performance Tools\"/>
  </Target>
  <!--Gathering code metrics on all soultion. In Debug mode, 
  output will be written in Metrics.xml file-->
  <Target Name="CodeMetrics">
    <Message Text="Gathering Code Metrics" />
    <ExportCodeMetrics
              CodeMetrics="$(CodeMetrics)"
              SolutionFile="CustomTasks.sln"
              OutputFile="Metrics.xml"
              Parmaters =""
              Configuration="Debug"
              />
  </Target>
</Project>

